/*
 * TimestampConverter.java
 * 
 * Created on 29/10/2007, 05:54:59 PM
 * 
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package view.common.struts;

import java.sql.Time;
import java.text.ParseException;
import java.util.Date;
import java.text.SimpleDateFormat;
//import model.common.constants.ValueConstants;
import org.apache.commons.beanutils.Converter;

/**
 * @Archivo TimeConverter.java
 * @Fecha                @Autor   @Cambios
 * 21/01/2011 02:22:14 PM       moshiro
 */
public class TimeConverter implements Converter {

    public TimeConverter() {
    }

    public Object convert(Class arg0, Object arg1) {
        if(arg1!=null && !arg1.equals("")){
            try {
                SimpleDateFormat sdf = new SimpleDateFormat("hh:mm:ss");
                Date date = sdf.parse(String.valueOf(arg1));
                return new Time(date.getTime());
            } catch (ParseException ex) {
                ex.printStackTrace();
                return null;
            }
        }
        else
        return null;
    }
}
